from app.api import abstract

MAX_ITEMS = 200

class Action(abstract.Action):
    def _get(self):
        
        wishes = abstract.models.reservation.listByUser(self.viewer_id)
        
        data = []
            
        for wish in wishes:
            wish_key = wish.key()
            wish_id = wish_key.id()
            wish_ids = abstract.utils.id2ids(wish_id)
            
            if wish.image != None:
                img_url = abstract.config.IMG_URL + "?id=" + wish_ids + "&nc=" + wish.updated.strftime("%d%m%y%H%M%S")
            else:
                img_url = ""
            
            row = {"wish_id" : wish_ids, "price_from" : wish.price_from, "price_to" : wish.price_to, "owner_id" : wish.owner_id, "title" : wish.title, 
                       "link" : wish.link , "img_url" : img_url, "tags" : wish.tags,
                       "reason_id" : wish.reason_id, "status" : wish.status, "updated" : wish.updated.strftime("%d.%m.%y %H:%M:%S")}
            
            data.append(row)
        
        return data